import { Injectable } from '@nestjs/common'
import { Category } from '../entities/category.entity'
import { InjectRepository } from '@nestjs/typeorm'
import { Subcategory } from '../entities/subcategory.entity'
import { Repository } from 'typeorm'

@Injectable()
export class CategoryService {
  constructor(
    @InjectRepository(Category)
    private readonly categoryRepository: Repository<Category>,
    @InjectRepository(Subcategory)
    private readonly subcategoryEntityRepository: Repository<Subcategory>,
  ) {}

  async queryCategory() {
    return await this.categoryRepository.find()
  }

  async querySubCategory(maitKey: string) {
    return await this.subcategoryEntityRepository.find({ where: { maitKey } })
  }
}
